package o;

import android.content.Context;
import android.media.browse.MediaBrowser.MediaItem;
import android.os.Bundle;
import android.os.Parcel;
import android.service.media.MediaBrowserService;
import android.service.media.MediaBrowserService.Result;
import android.support.v4.media.session.MediaSessionCompat;
import android.util.Log;
import androidx.annotation.RequiresApi;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import o.lo.b;

@RequiresApi(26)
public class lq {
    static Field ˊ;

    public interface d extends b {
        void ˎ(String str, c cVar, Bundle bundle);
    }

    static class a extends d {
        a(Context context, d dVar) {
            super(context, dVar);
        }

        public void onLoadChildren(String str, Result<List<MediaItem>> result, Bundle bundle) {
            MediaSessionCompat.ˏ(bundle);
            ((d) this.ˏ).ˎ(str, new c(result), bundle);
        }
    }

    public static class c {
        Result ˊ;

        c(Result result) {
            this.ˊ = result;
        }

        public void ˊ(List<Parcel> list, int i) {
            try {
                lq.ˊ.setInt(this.ˊ, i);
            } catch (Throwable e) {
                Log.w("MBSCompatApi26", e);
            }
            this.ˊ.sendResult(ˏ(list));
        }

        List<MediaItem> ˏ(List<Parcel> list) {
            if (list == null) {
                return null;
            }
            List<MediaItem> arrayList = new ArrayList();
            for (Parcel parcel : list) {
                parcel.setDataPosition(0);
                arrayList.add(MediaItem.CREATOR.createFromParcel(parcel));
                parcel.recycle();
            }
            return arrayList;
        }
    }

    static {
        try {
            ˊ = Result.class.getDeclaredField("mFlags");
            ˊ.setAccessible(true);
        } catch (Throwable e) {
            Log.w("MBSCompatApi26", e);
        }
    }

    public static Object ˊ(Context context, d dVar) {
        return new a(context, dVar);
    }

    public static void ˎ(Object obj, String str, Bundle bundle) {
        ((MediaBrowserService) obj).notifyChildrenChanged(str, bundle);
    }

    public static Bundle ˊ(Object obj) {
        return ((MediaBrowserService) obj).getBrowserRootHints();
    }
}
